<template>
  <!-- 承装轮播图的整体容器 -->
  <div class="swiper-container">
    <!-- 承装每一屏 -->
    <div class="swiper-wrapper">
      <div
        class="swiper-slide"
        v-for="nav in navList.slice(0, 6)"
        :key="nav.id"
      >
        <div class="one">
          <a :href="nav.columnUrl">
            <img :src="nav.picUrl" alt="" />
          </a>

          <p class="god">{{ nav.mainTitle }}</p>
          <p>{{ nav.viceTitle }}</p>
        </div>
        <div
          class="one"
          v-for="nav in navList.slice(nav.rank + 6, nav.rank + 7)"
          :key="nav.id"
        >
          <a :href="nav.columnUrl">
            <img :src="nav.picUrl" alt="" />
          </a>

          <p class="god">{{ nav.mainTitle }}</p>
          <p>{{ nav.viceTitle }}</p>
        </div>
      </div>
    </div>
    <!-- 小圆点 -->
    <div class="swiper-pagination"></div>
    <!-- 上一张、下一张按钮 -->
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/css/swiper.min.css";
export default {
  name: "ImageList",
  props: ["navList"],
  watch: {
    navList() {
      this.$nextTick(() => {
        new Swiper(".swiper-container", {
          observer: true, // 修改swiper自己或子元素时，自动初始化swiper
          observeParents: true, // 修改swiper的父元素时，自动初始化swiper
          spaceBetween: 0, //每一屏之间的距离
          speed: 500, //屏的切换速度
          slidesPerView: "auto", //同时展示几屏
          pagination: {
            el: ".swiper-pagination", //小圆点容器
            clickable: true, //小圆点是否可以点击
          },
        });
      });
    },
  },
};
</script>

<style lang="less" scoped>
.swiper-container {
  height: 270px;
  width: 100%;
  .swiper-pagination.swiper-pagination-bullets {
    bottom: 0.18rem;
    .swiper-pagination .swiper-pagination-bullet {
      width: 0.392rem;
      height: 0.04rem;
      background: #d9d9d9;
      margin: 0 !important;
      border-radius: 0;
      opacity: 1;
    }
  }
  .swiper-slide {
    width: 25%;
    height: 270px;
    .one {
      margin: 0.5rem auto;
      display: block;
      p {
        font-size: 0.3rem;
        text-align: center;
        line-height: 0.44rem;
        &.god {
          font-size: 0.36rem;
          font-weight: 900;
        }
      }
      img {
        width: 1.6rem;
        height: 1.6rem;
        display: block;
        margin: 0 auto 0.2rem;
      }
    }
  }
}
</style>